package com.spic.system.api.factory;

import com.spic.common.core.domain.R;
import com.spic.system.api.RemoteBusinessService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

/**
 * @Description 业务服务错误处理
 * @Author wzl
 * @Date 2022/03/16
 */
@Component
public class RemoteBusinessFallBackFactory implements FallbackFactory<RemoteBusinessService> {

    @Override
    public RemoteBusinessService create(Throwable cause) {
        return new RemoteBusinessService(){
            @Override
            public R<Object> monitorRainfall() {
                return R.fail("定时任务失败:" + cause.getMessage());
            }
            @Override
            public R<Object> consumersHkAlarm() {
                return R.fail("定时任务失败:" + cause.getMessage());
            }
            @Override
            public R<Object> getPresets() {
                return R.fail("定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> getCameraSearch()
            {
                return R.fail("定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> getDoorEventsTask(@RequestBody Map<String,Object> map) {
                return R.fail("定时任务失败:" + cause.getMessage());
            }
            @Override
            public R<Object> getDoorSearchList()
            {
                return R.fail("定时任务失败:" + cause.getMessage());
            }
            @Override
            public R<Object> docSendMsg(String id)
            {
                return R.fail("公文督办定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> hiddenSendMsg(String id)
            {
                return R.fail("隐患督办定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> getFplAlarmData()
            {
                return R.fail("隐患督办定时任务失败:" + cause.getMessage());
            }



            @Override
            public R<Object> saveBpGnss()
            {
                return R.fail("边坡位移实时数据定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> saveBpPositionData()
            {
                return R.fail("边坡测点定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> saveBpAlarm()
            {
                return R.fail("边坡告警定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> contractorPersistent() {
                return R.fail("承包商人员信息融入安全系统用户表定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> addContractorPerson() {
                return R.fail("承包商人员同步海康定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> authAccess() {
                return R.fail("承包商人员分配门禁权限定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> accessAuthByPage() {
                return R.fail("承包商人员前端页面分配门禁权限定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> addDriver() {
                return R.fail("同步驾驶人至海康定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> syncPlate() {
                return R.fail("同步车牌至海康定时任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> sendNotic(Long userId,String name)
            {
                return R.fail("发通知任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> pushMessage() {
                return R.fail("发流程待办通知任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> syncTrainCertificate() {
                return R.fail("人员证书同步任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> syncOilWear() {
                return R.fail("同步油耗任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> filterCarDirtyData() {
                return R.fail("数据治理同步车辆脏数据任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> filterIllegalCaptureDirtyData() {
                return R.fail("数据治理同步违章抓拍脏数据任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> filterViolationInformationDirtyData() {
                return R.fail("数据治理同步违章举报脏数据任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> filterViolationActionInputDirtyData() {
                return R.fail("数据治理同步反违章检查脏数据任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> filterBlastDirtyData() {
                return R.fail("数据治理同步爆区布防脏数据任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> filterMeetingBeforeDirtyData() {
                return R.fail("数据治理同步班前班后会脏数据任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> createTrain() {
                return R.fail("违章举报创建培训任务失败:" + cause.getMessage());
            }

            @Override
            public R<Object> inputCreateTrain() {
                return R.fail("违章行为录入创建培训任务失败:" + cause.getMessage());
            }


        };
    }
}
